package com.yanqu.road.logic.activity.tomb.config.entity;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.yanqu.road.utils.serialize.StringToListInt;
import com.yanqu.road.utils.serialize.StringToListListInt;

import java.util.List;
import java.util.Random;

public class ActivityTombFloor {
    private int activityId;
    private int id;

    @JsonDeserialize(using = StringToListInt.class)
    private List<Integer> floor;

    private int energy;

    private int buffEventNum;

    @JsonDeserialize(using = StringToListListInt.class)
    private List<List<Integer>> EliteEventWeight;
    @JsonDeserialize(using = StringToListListInt.class)
    private List<List<Integer>> eventWeight;

    private int monsterHpAdd;

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public List<Integer> getFloor() {
        return floor;
    }

    public void setFloor(List<Integer> floor) {
        this.floor = floor;
    }

    public int getEnergy() {
        return energy;
    }

    public void setEnergy(int energy) {
        this.energy = energy;
    }

    public List<List<Integer>> getEventWeight() {
        return eventWeight;
    }

    public void setEventWeight(List<List<Integer>> eventWeight) {
        this.eventWeight = eventWeight;
    }

    public int getMonsterHpAdd() {
        return monsterHpAdd;
    }

    public void setMonsterHpAdd(int monsterHpAdd) {
        this.monsterHpAdd = monsterHpAdd;
    }

    public int getTotalEventNum() {
        int total = 0;
        for (List<Integer> eventList : this.getEventWeight()) {
            total = total + eventList.get(1);
        }
        return total;
    }

    public int getBuffEventNum() {
        return buffEventNum;
    }

    public void setBuffEventNum(int buffEventNum) {
        this.buffEventNum = buffEventNum;
    }

    public List<List<Integer>> getEliteEventWeight() {
        return EliteEventWeight;
    }

    public void setEliteEventWeight(List<List<Integer>> eliteEventWeight) {
        EliteEventWeight = eliteEventWeight;
    }


    public int randEliteNpc() {
        int total = 0;
        for (List<Integer> integerList : this.EliteEventWeight) {
            total = total + integerList.get(1);
        }
        Random random = new Random();
        int i = random.nextInt(total);
        for (List<Integer> integerList : this.EliteEventWeight) {
            if (i < integerList.get(1)) {
                return integerList.get(0);
            } else {
                i = i - integerList.get(1);
            }
        }
        return 0;
    }

}
